package com.feihong.txgw.tx_precenter;

import android.util.Log;

import com.feihong.txgw.inter.contract.user.IUserInfoEditContract;
import com.feihong.txgw.tx_model.UserInfoEditMainModel;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import okhttp3.MultipartBody;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName UserInfoEditMainPrecenter
 * @package com.feihong.txgw.tx_precenter
 * @data 2018/5/7 20:20
 * @Describe
 * @Change
 */
public class UserInfoEditMainPrecenter extends IUserInfoEditContract.AbUserInfoEditMainPrecenter {
    @Override
    public void getUserInfo(String type, String info) {
        mIModel.getUserInfo(type,info).subscribe(new Observer<String>() {
            @Override
            public void onSubscribe(Disposable d) {
                mRxManager.register(d);
            }

            @Override
            public void onNext(String s) {
                mIView.getUserInfoResult(s);
            }

            @Override
            public void onError(Throwable e) {
                mIView.getUserInfoError();
            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void upLoadUserImg(MultipartBody.Part file) {
        mIModel.upLoadUserImg(file).subscribe(new Observer<String>() {
            @Override
            public void onSubscribe(Disposable d) {
                mRxManager.register(d);
            }

            @Override
            public void onNext(String s) {
                mIView.upLoadUserImgResult(s);
            }

            @Override
            public void onError(Throwable e) {
                mIView.upLoadUserImgError();
            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public IUserInfoEditContract.IUserInfoEditMainModel getModel() {
        return UserInfoEditMainModel.create();
    }

    @Override
    public void onStart() {

    }

    public static UserInfoEditMainPrecenter create(){
        return new UserInfoEditMainPrecenter();
    }
}
